/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import org.apache.log4j.Logger;

import com.taobao.wolfwolf.hibernate.dao.MaterialDao;
import com.taobao.wolfwolf.hibernate.pojo.Material;
import com.taobao.wolfwolf.hibernate.service.MaterialService;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-17 下午03:11:31
 */
public class MaterialServiceImpl extends BaseServiceImpl implements MaterialService {
	private MaterialDao mdao;
	private static Logger logger = Logger.getLogger(MaterialServiceImpl.class);

	public List<Material> findAll() {
		try {
			return mdao.findAll();
		} catch(Exception e) {
			logger.error(e);
			e.printStackTrace();
		}
		return null;
	}

	public Material findById(int id) {
		try {
			return mdao.findById(id);
		} catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at findById(int id)");
		}
		return null;
	}

	public List<Material> findByName(String name) {
		try {
			return mdao.findByName(name);
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at findByName(String name)");
		}
		return null;
	}

	public long getTotal()  {
		try {
			return mdao.getTotal();
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at getTotal()");
		}
		return -1;
	}

	public List<Material> paging(int page, int limit)  {
		try {
			return mdao.paging(page, limit);
		}  catch (Exception e) {
			logger.error(e);
			e.printStackTrace();
			System.out.println("Error at paging(int page, int limit)");
		}
		return null;
	}

	public void setmdao(MaterialDao mdao) {
		this.mdao = mdao;
	}

	public MaterialDao getmdao() {
		return mdao;
	}
}
